package com.ejiaoyi.api.service.impl;

import com.ejiaoyi.api.dto.GetToken;
import com.ejiaoyi.api.service.IBaseService;
import com.ejiaoyi.api.util.ApiUtil;
import com.ejiaoyi.common.util.DesUtil;
import com.ejiaoyi.common.util.RedisUtil;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * 基础 服务实现类
 *
 * @author unknownChivalrous
 * @since 2020-4-21
 */
@Component
public class BaseServiceImpl implements IBaseService {

    @Override
    public String getToken(GetToken getToken) {
        String uuid = UUID.randomUUID().toString();

        String encrypt = DesUtil.encrypt(getToken.getApiKey() + "-" + getToken.getPlatform());

        RedisUtil.set(uuid, encrypt, ApiUtil.API_REDIS_TIMEOUT);

        return uuid;
    }
}
